use std::sync::Mutex;


pub  struct  Race{
    name: String,
    laps:Vec<i32>
}

impl Race {
    pub(crate) fn new(name: &str) -> Self{
        Self{name:String::from(name),laps:Vec::new()}
    }
    
    pub(crate) fn add_lap(&mut self, lap:i32){
        self.laps.push(lap)
    }
    
    pub(crate) fn print_laps(&self){
        
        println!("Record{} for {}",self.laps.len(),self.name);
        for (idx,lap) in self.laps.iter().enumerate(){
            println!("Lap{idx}: {lap} sec")
        }
    }
    
    pub(crate) fn finish(self){
        let total:i32=self.laps.iter().sum();
        println!("Race {} is finished , total lap time:{}",self.name,total);
    }
}

